package com.ruoyi.socket.discard;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import io.netty.util.ReferenceCountUtil;

/***
 *  @description
 *  @author zhao
 *  @date: 2020/6/12
 *  @version: v1.0
 */
public class DiscardServerOutboundHandler extends ChannelOutboundHandlerAdapter {



    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {

        System.out.println("出站消息" +msg);
        ReferenceCountUtil.release(msg); //丢弃服务，主动释放出站内容
        promise.setSuccess();//  通知ChannelPromise数据已被处理

//        ctx.write(msg, promise);
    }

}
